$(document).ready(function(){
	$("select").each(function(){
		$(this).select2();
	});

	if($('#datatable')){
		var aoColumns = [];
		$('#datatable th').each(function(){
			aoColumns.push({mDataProp:$(this).attr("data-name")});
		});

		var obTable = $('#datatable').dataTable({
                aaSorting:[],
                "bSort": false, 
                "bFilter":false,
                "bProcessing": true,
                "bServerSide": true,
                "sAjaxSource": $('#datatable').attr('data-url'),
                "iDisplayLength": 10,
                "sPaginationType": "bootstrap",
                "oLanguage": {
                    "sProcessing": ' <i class="fa fa-coffee"></i>&nbsp;数据加载中...',
                    "sLengthMenu": "_MENU_ records",
                    "oPaginate": {
                        "sPrevious": "Prev",
                        "sNext": "Next"
                    },
                    "sInfo": " _START_ - _END_ /共 _TOTAL_ 条数据",
                },
                'bLengthChange':false,
                'fnServerParams': function (aoData) {
                    var data = $('#searchForm').serializeArray();
                    for(var i in data)
                        aoData.push(data[i]);
                },
                'aoColumns':aoColumns,
                "aoColumnDefs":aoColumnDefs
            });

		$('#searchButton').click(function(){
            obTable._fnReDraw();
            return false;
        });
	}


	$('form').submit(function(){
            if ($("form").valid()==false)
                return false;

                 
                return true;
            });
	
});